package com.bristua.barcode.supplier.biz;

import com.bristua.barcode.common.bean.PageBean;
import com.bristua.barcode.supplier.dao.TChannelMapper;
import com.bristua.barcode.supplier.model.TChannel;
import com.bristua.barcode.supplier.model.TSupplier;
import com.bristua.barcode.supplier.model.condition.QueryChannelParams;
import com.bristua.barcode.supplier.model.condition.QuerySupplierParams;
import com.bristua.barcode.supplier.model.condition.TChannelExample;
import com.bristua.barcode.supplier.model.condition.TSupplierExample;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2019/9/5.
 */
@Service
public class QueryChannelBiz {
    @Resource
    private TChannelMapper tChannelMapper;

    public PageBean<TChannel> queryChannel(QueryChannelParams queryChannelParams){

        TChannelExample tChannelExample = new TChannelExample();

        if(!StringUtils.isEmpty(queryChannelParams.getChannelName())){
            tChannelExample.createCriteria().andChannelNameLike("%"+queryChannelParams.getChannelName()+"%");
        }

        tChannelExample.setOrderByClause("create_time desc");

        Page<TChannel> objects = PageHelper.startPage(queryChannelParams.getPageNo(),queryChannelParams.getPageSize());

        tChannelMapper.selectByExample(tChannelExample);

        return new PageBean<>(objects);
    }
}
